|
|
|
|
|
|
|
Figure 11.19
Program Bezier2 displaying a high-order Bezier curve. |
|
|
|
|
|
|
|
|
Example program Bezier2, shown in Figure 11.19, demonstrates this code. Click with the mouse to create a series of control points. When you click the Go button, the program displays the corresponding Bezier curve. While the curve is displayed, you can use the mouse to drag the control points to see the effect on the curve. If you click the New button, the program clears the screen and lets you select a new set of control points. |
|
|
|
|
|
|
|
|
Notice that the curve in Figure 11.19 does not touch any control points except the two endpoints. The other control points determine only the general shape of the curve. |
|
|
|
|
|
|
|
|
By correctly placing control points, you can give a higher-order Bezier curve the general shape you want it to have. One inconvenient feature of Bezier curves is that the value of every point on the curve, except the endpoints, depends on the location of every control point. If you move one control point in the middle of the curve, the entire curve changes slightly. As a result, you cannot adjust the shape of the curve locally without affecting its shape globally. |
|
|
|
|
|
|
|
|
One way to make a curve with local control is to build it using several different Bezier curves connected at their endpoints. You can then modify the control points of one curve to change its shape without changing the shapes of the other curves. If you want the curves to meet smoothly, you may also need to adjust one of the neighboring curve's control points so that the tangents of the two curves remain pointed in the same direction. |
|
|
|
|
|
|
|
|
B-splines give you a simpler way to create a complicated curve with local control. The basic construction of a B-spline is similar to that of a Bezier curve defined using blending functions. Suppose you have N + 1 control points with coordinates (x0, y0), (x1, y1), . . ., (xN, yN) You can write the equation for the X coordinate of a B-spline as: |
|
|
|
 |
|
|
|
|
X(t) = S xi * Bi,k(t) |
|
|
|
|
|
|
|
|
where the Bi,k(t) are the curve's blending functions. The parameter k determines the smoothness of the curve. If k is small, the curve matches the data points relatively closely. |
|
|
|
|
|